/*
*    Phantom Test Driver v2.0 GUI Automation Software
*    Copyright (C) 2009  John C. Van Arsdall (john@phantomtest.com)
*
*    This program is free software; you can redistribute it and/or modify
*    it under the terms of the GNU General Public License as published by
*    the Free Software Foundation; either version 2 of the License, or
*    (at your option) any later version.
*
*    This program is distributed in the hope that it will be useful,
*    but WITHOUT ANY WARRANTY; without even the implied warranty of
*    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
*    GNU General Public License for more details.
*
*    You should have received a copy of the GNU General Public License along
*    with this program; if not, write to the Free Software Foundation, Inc.,
*    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
*/
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package ptd;

import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.MouseMotionAdapter;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.Icon;
import javax.swing.ImageIcon;
import javax.swing.JLabel;
import javax.swing.JWindow;

/**
 *
 * @author John
 */
public class PTDSplashScreen extends JWindow {

    public class SplashThread extends java.lang.Thread{    

        private PTDSplashScreen pW;
        /** Creates a new instance of PTDSuiteThread */
        public SplashThread(PTDSplashScreen Par) {
            pW = Par;
        }

        public void run(){
            try {
                Thread.currentThread().sleep(2000);
            } catch (InterruptedException ex) {
                Main.debug_out(ex.getMessage());
            }
            pW.dispose();
        }
    }

    
	private int X = 0;
	private int Y = 0;
	public PTDSplashScreen(int xloc, int yloc) {
		setBounds(xloc-250, yloc-150, 500, 300);
		addWindowListener(new WindowAdapter() {
			public void windowClosing(WindowEvent e) {
				//System.exit(0); // An Exit Listener
			}
		});
		// Print (X,Y) coordinates on Mouse Click
//		addMouseListener(new MouseAdapter() {
//			public void mousePressed(MouseEvent e) {
//				X = e.getX();
//				Y = e.getY();
				//Main.debug_out("The (X,Y) coordinate of window is ("
				//		+ X + "," + Y + ")");
//			}
//		});
//		addMouseMotionListener(new MouseMotionAdapter() {
//
//			public void mouseDragged(MouseEvent e) {
//				setLocation(getLocation().x + (e.getX() - X),
//						getLocation().y + (e.getY() - Y));
//			}
//		});
               
                JLabel J = new JLabel();
                ImageIcon a = PTDImageLoader.getImageIcon(PTDImageLoader.IMG_SPLASH_SCREEN);    
                J.setIcon(a);
                add(J);
                
                setVisible(true);
                setAlwaysOnTop(true);
	}
        
        public void start_timer(){
                SplashThread aThread = new SplashThread(this);
                aThread.start();            
        }
}